/*!
 * \file      board.h
 *
 * \brief     Target board general functions implementation
 *
 * \copyright Revised BSD License, see section \ref LICENSE.
 *
 * \code
 *                ______                              _
 *               / _____)             _              | |
 *              ( (____  _____ ____ _| |_ _____  ____| |__
 *               \____ \| ___ |    (_   _) ___ |/ ___)  _ \
 *               _____) ) ____| | | || |_| ____( (___| | | |
 *              (______/|_____)_|_|_| \__)_____)\____)_| |_|
 *              (C)2013-2017 Semtech
 *
 * \endcode
 *
 * \author    Miguel Luis ( Semtech )
 *
 * \author    Gregory Cristian ( Semtech )
 */
#ifndef __BOARD_H__
#define __BOARD_H__

#include <stdint.h>
#include "tremo_regs.h"
#include "tremo_rcc.h"
#include "system.h"


#if defined(CONFIG_DTU_485)	
//看门狗喂狗管脚 GPIO00
#define SYSTEM_WATCHDOG_RCC         (RCC_PERIPHERAL_GPIOA)
#define SYSTEM_WATCHDOG_GPIO        (GPIOA)
#define SYSTEM_WATCHDOG_PIN         (GPIO_PIN_0)
#endif

#if defined(CONFIG_DTU_DOUT)	
//看门狗喂狗管脚 GPIO00
#define SYSTEM_WATCHDOG_RCC         (RCC_PERIPHERAL_GPIOA)
#define SYSTEM_WATCHDOG_GPIO        (GPIOA)
#define SYSTEM_WATCHDOG_PIN         (GPIO_PIN_0)


//DOUT1  GPIO00
#define SYSTEM_DOUT1_RCC            (RCC_PERIPHERAL_GPIOA)
#define SYSTEM_DOUT1_GPIO           (GPIOA)
#define SYSTEM_DOUT1_PIN            (GPIO_PIN_0)

//DOUT2  GPIO03
#define SYSTEM_DOUT2_RCC            (RCC_PERIPHERAL_GPIOA)
#define SYSTEM_DOUT2_GPIO           (GPIOA)
#define SYSTEM_DOUT2_PIN            (GPIO_PIN_3)


void SystemDoutConfig(void);
void SystemDoutModeSet(uint8_t attrId,uint8_t state);

#endif




#if defined(CONFIG_DTU_DIN)	
//看门狗喂狗管脚 GPIO00
#define SYSTEM_WATCHDOG_RCC         (RCC_PERIPHERAL_GPIOA)
#define SYSTEM_WATCHDOG_GPIO        (GPIOA)
#define SYSTEM_WATCHDOG_PIN         (GPIO_PIN_0)


//DIN1  GPIO00
#define SYSTEM_DIN1_RCC            (RCC_PERIPHERAL_GPIOA)
#define SYSTEM_DIN1_GPIO           (GPIOA)
#define SYSTEM_DIN1_PIN            (GPIO_PIN_0)

//DIN2  GPIO03
#define SYSTEM_DIN2_RCC            (RCC_PERIPHERAL_GPIOA)
#define SYSTEM_DIN2_GPIO           (GPIOA)
#define SYSTEM_DIN2_PIN            (GPIO_PIN_3)


//DIN3  GPIO04
#define SYSTEM_DIN3_RCC            (RCC_PERIPHERAL_GPIOA)
#define SYSTEM_DIN3_GPIO           (GPIOA)
#define SYSTEM_DIN3_PIN            (GPIO_PIN_4)


//DIN4  GPIO47
#define SYSTEM_DIN4_RCC            (RCC_PERIPHERAL_GPIOA)
#define SYSTEM_DIN4_GPIO           (GPIOC)
#define SYSTEM_DIN4_PIN            (GPIO_PIN_14)

void SystemDinConfig(void);
uint8_t SystemDinModeGet(uint8_t attrId);

#endif





/*!
 * \brief Initializes the mcu.
 */
void BoardInitMcu( void );


/*!
 * \brief Initializes the boards peripherals.
 */
void BoardInitPeriph( void );

/*!
 * \brief De-initializes the target board peripherals to decrease power
 *        consumption.
 */
void BoardDeInitMcu( void );


void WatchDogConfig(void);
void WatchDogToggle(void);

void SystemEnterSleep(void);

#endif // __BOARD_H__
